package com.acwing.lc.part1;

import java.io.*;

/**
 * @author rkc
 * @date 2022/9/5 16:27
 */
public class LC6Z字形变换 {

    private static final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    private static final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));

    public static void main(String[] args) throws IOException {
        String[] ss = reader.readLine().split(" ");
        writer.write(convert(ss[0], Integer.parseInt(ss[1])));
        writer.flush();
    }

    public static String convert(String s, int n) {
        if (n == 1) return s;
        StringBuilder ans = new StringBuilder();
        for (int i = 0; i < n; i++) {
            if (i == 0 || i == n - 1) {
                for (int j = i; j < s.length(); j += 2 * n - 2) ans.append(s.charAt(j));
            } else {
                for (int j = i, k = 2 * n - 2 - i; j < s.length() || k < s.length(); j += 2 * n - 2, k += 2 * n - 2) {
                    if (j < s.length()) ans.append(s.charAt(j));
                    if (k < s.length()) ans.append(s.charAt(k));
                }
            }
        }
        return ans.toString();
    }
}
